'''
Created on Nov 18, 2009

@author: Owner
'''
import gamephase.game_phase
import interface.ConsoleAgent
import __builtin__

class AbstractCheckerGameMode(gamephase.game_phase.GamePhase):
	'''
	classdocs
	'''

	def __init__(self):
		'''
		Constructor
		'''
		self.last_moved_player = None
		self.last_move = None
		
	def getGameState(self):
		raise NotImplementedError("execute")
	
	def setGameState(self):
		raise NotImplementedError("execute")
	
	def annouceLastMove(self):
		if self.last_move != None and self.last_moved_player != None:
			interface.ConsoleAgent.ConsoleDescriptor\
			.annouceMove(self.last_move, self.last_moved_player)
	
	def take_move(self, move):
		self.last_moved_player = self.state.getCurrentPlayer()
		self.last_move = move
		
		# record one move for reference
		tmp_move = self.getGameState().successorMove()[0]
		
		self.setGameState(
			self.getGameState().take_checker_move(move)
		)
		
		# is this move a complete CheckerMove? if not(a first partial CheckerMove),
		# we still need the same player to take move, then don't switch player
		if move.getLength() == tmp_move.getLength():
			self.state.switchPlayer()
	
	def end_game(self):
		__builtin__.G.game_phase = gamephase.game_phase.GamePhaseEnd()
		pass
		